package com.heima.test;

import com.heima.common.aliyun.GreenImageScan;
import com.heima.common.aliyun.GreenTextScan;
import com.heima.file.service.FileStorageService;
import com.heima.wemedia.WemediaApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.green20220302.Client;
import com.aliyun.green20220302.models.TextModerationRequest;
import com.aliyun.green20220302.models.TextModerationResponse;
import com.aliyun.green20220302.models.TextModerationResponseBody;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teautil.models.RuntimeOptions;
@SpringBootTest(classes = WemediaApplication.class)
@RunWith(SpringRunner.class)
public class aliyunText {
    @Autowired
    private GreenTextScan greenTextScan;
    @Autowired
    private FileStorageService fileStorageService;
    @Autowired
    private GreenImageScan greenImageScan;

    /**
     * 测试文章的审核
     */
    @Test
    public void test() throws Exception {
        Map map = greenTextScan.greeTextScan("你好,天小星");
        System.out.println(map);

    }

    /**
     * 测试文本内容审核
     */
    @Test
    public void  TestScanText() throws Exception {
        Map map = greenTextScan.greeTextScan("我要去赌博");
        System.out.println(map);
    }


    @Test
    public void testImage() throws Exception {
        try {
            byte[] bytes = fileStorageService.downLoadFile("http://192.168.200.130:9000/leadnews/2025/03/11/7038190d388849e991a0711b8463ce0b.jpg");
            ArrayList<byte[]> bytes1 = new ArrayList<>();
            bytes1.add(bytes);
            Map map = greenImageScan.imageScan(bytes1);
            System.out.println(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
